test(pgshare): extract shared db-acquisition + schema-isolation core (RIG-2903) - #704
Merged
Merged
Conversation
rigel-mintaka
marked this pull request as draft
August 28, 2026 03:30
|
Compass engineering docs preview: https://compass-rig-2903-pgshare-ext.compass-eng-docs.pages.dev Deployed from |
rigel-mintaka
force-pushed
the
compass/rig-2903-pgshare-extract
branch
from
August 28, 2026 03:53
ee26f85 to
46f8672
Compare
…(RIG-2903) T1 of the Go test-harness-tiers consolidation (design RIG-2742, #684). Extracts the one copy of the real-Postgres acquisition policy + per-test schema isolation out of `internal/pgtest` into a new shared `internal/pgshare` package, so the suite-postgres lanes (T2+) can build on the same core without an import cycle. ## What moves `internal/pgshare/pgshare.go` (build tag `(pgtest || podman) && unix`) holds the acquisition policy + schema isolation **verbatim** — `decideDSNSource` + the 5 sources, `containerCLI`, `startContainer`, `removeContainerArgs`, `publishedPort`, `waitReady`, `schemaSeq`, `withSearchPath` (incl. the existing-`options` panic guard) — exposed as the record's three produced interfaces: `AcquireDSN(t)`, `IsolatedSchemaDSN(t, dsn)`, `StartSuitePostgres(tb, stateDir, sockDir, port)`, plus the TB-free `StartSuitePostgresMain` variant for TestMain (both delegate to one unexported bring-up body). `internal/pgtest/pgtest.go` becomes a thin delegator: `RequireDSN` now returns `pgshare.AcquireDSN(t)`; its exported surface (`DSNEnvVar`/`UseContainerEnvVar`/`RequireLiveEnvVar` + `RequireDSN`) is **byte-for-byte unchanged**, so none of the 30 integration call-sites move. The three white-box unit tests of the extracted internals (`TestDecideDSNSource`, `TestRemoveContainerArgsCarriesVolumesFlag`, `TestThrowawayContainerLeavesNoDanglingVolume`) move with their code into `pgshare_test.go`, names/assertions byte-identical; a new `TestStartSuitePostgresMainErrors` covers the TB-free error paths (empty state dir, binary-not-on-PATH). ## Verification gofmt clean; `go build ./...` clean; `go vet -tags 'pgtest unix'` clean across pgshare, pgtest, and the store/board/server consumers; `go test -tags 'pgtest unix' ./internal/pgshare/` green (all moved tests run, container test spins a real throwaway Postgres). Spec-impact: none. Refs RIG-2903 Co-authored-by: Matt Wilkinson <matt@rigel.build>
rigel-mintaka
force-pushed
the
compass/rig-2903-pgshare-extract
branch
from
August 28, 2026 04:07
46f8672 to
a1bbed9
Compare
rigel-mintaka
marked this pull request as ready for review
August 28, 2026 05:09
mattwilkinsonn
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
T1 of the Go test-harness-tiers consolidation (design RIG-2742, #684). Extracts the one copy of the real-Postgres acquisition policy + per-test schema isolation out of
internal/pgtestinto a new sharedinternal/pgsharepackage, so the suite-postgres lanes (T2+) can build on the same core without an import cycle.What moves
internal/pgshare/pgshare.go(build tag(pgtest || podman) && unix) holds the acquisition policy + schema isolation verbatim —decideDSNSource+ the 5 sources,containerCLI,startContainer,removeContainerArgs,publishedPort,waitReady,schemaSeq,withSearchPath(incl. the existing-optionspanic guard) — exposed as the record's three produced interfaces:AcquireDSN(t),IsolatedSchemaDSN(t, dsn),StartSuitePostgres(tb, stateDir, sockDir, port), plus the TB-freeStartSuitePostgresMainvariant for TestMain (both delegate to one unexported bring-up body).internal/pgtest/pgtest.gobecomes a thin delegator:RequireDSNnow returnspgshare.AcquireDSN(t); its exported surface (DSNEnvVar/UseContainerEnvVar/RequireLiveEnvVar+RequireDSN) is byte-for-byte unchanged, so none of the 30 integration call-sites move.The three white-box unit tests of the extracted internals (
TestDecideDSNSource,TestRemoveContainerArgsCarriesVolumesFlag,TestThrowawayContainerLeavesNoDanglingVolume) move with their code intopgshare_test.go, names/assertions byte-identical; a newTestStartSuitePostgresMainErrorscovers the TB-free error paths (empty state dir, binary-not-on-PATH).Verification
gofmt clean;
go build ./...clean;go vet -tags 'pgtest unix'clean across pgshare, pgtest, and the store/board/server consumers;go test -tags 'pgtest unix' ./internal/pgshare/green (all moved tests run, container test spins a real throwaway Postgres).Spec-impact: none. Refs RIG-2903
Co-authored-by: Matt Wilkinson matt@rigel.build